<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script src="https://cdn.staticfile.org/jquery/2.2.4/jquery.min.js"></script>
    <script>
        var targetObj = {
            id: 0,
            msg: {
                sex: 18
            }
        }

        var obj = {
            id: 1,
            name: "andy",
            msg: {
                age: 18
            }
        }

        $.extend(targetObj, obj);
        // console.log(targetObj); // 会覆盖targetObj 里面原来的数据
        // targetObj.msg.age = 20;
        console.log('targetObj', targetObj); // msg :{sex: "男", age: 20}
        console.log('obj', obj);
    </script>
</body>

</html>